package com.zwps.biz.controller.http;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import com.zwps.biz.api.model.vo.fourpipes.HiddenDangerCountVO;

import com.zwps.biz.api.model.vo.fourpipes.TrainVO;
import com.zwps.biz.api.model.vo.fourpipes.VillageLandInfoVO;
import com.zwps.biz.api.model.vo.fourpipes.*;

import com.zwps.biz.api.model.vo.pubpointall.DangerInfoDetailVO;
import com.zwps.biz.api.model.vo.pubpointall.HiddenDangerVO;

import com.zwps.biz.api.model.vo.pubpointall.ZAchievementsOtherVO;
import com.zwps.biz.api.model.vo.structure.*;

import com.zwps.biz.dal.db.object.ZAchievementsDO;
import com.zwps.biz.dal.db.object.ZEmergencyUserDO;

import com.zwps.biz.dal.db.object.ZSafetyAppraisalDO;
import com.zwps.biz.domain.service.*;
import com.zwps.common.controller.response.message.ResponseDataMessage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Tag(name = "四管")
@RestController
@RequestMapping("brief/pipes")
@Validated
public class FourPipesController {


    @Autowired
    VillageLandInfoService villageLandInfoService;
    @Autowired
    ZTrainRecordService zTrainRecordService;
    @Autowired
    ZEmergencyUserService zEmergencyUserService;
    @Autowired
    ZGoodsMaterialsService zGoodsMaterialsService;
    @Autowired
    ZEquipmentRecordService zEquipmentRecordService;

    @Autowired
    ZSafetyAppraisalService zSafetyAppraisalService;
    @Autowired
    ZWaterLawEnforcementService waterLawEnforcementService;
    /**
     * 库容侵占统计
     *
     * @return
     */
    @GetMapping("getvillageLandInfo")
    public List<VillageLandInfoVO> getvillageLandInfo() {
        return villageLandInfoService.getvillageLandInfo();
    }

    /**
     * 隐患问题整改
     *
     * @return
     */
    @GetMapping("getHiddenDangerCount")
    public HiddenDangerCountVO getHiddenDangerCount(@RequestParam("year") String year) {
        return villageLandInfoService.getHiddenDangerCount(year);
    }



    /**
     * 工作机制与培训
     *
     * @return
     */
    @GetMapping("getTrain")
    public TrainVO getTrain() {
        return villageLandInfoService.getTrain();
    }
//    /**
//     * 工程维养记录
//     * @return
//     */
//    @GetMapping("getTrain")
//    public TrainVO getTrain( ) {
//        return villageLandInfoService.getTrain();
//    }

    /**
     * 管理制度文档
     *
     * @return
     */
    @GetMapping("getFileByType")
    public List<PubCommonFileVO> getFileByType(@RequestParam(value = "type", required = false) Integer type) {
        return villageLandInfoService.getFileByType(type);
    }

    /**
     * 标准化管理手册
     *
     * @return
     */
    @GetMapping("getFiles")
    public List<PubCommonVO> getFileByTypes() {
        return villageLandInfoService.getFileByTypes();
    }


    /**
     * 培训计划与记录
     */
    @GetMapping("getTrainRecordByType")
    public TrainNewVO getTrainRecordByType(@RequestParam(value = "year", required = false) String year,
                                           @RequestParam(value = "type", required = false) String type) {
        return zTrainRecordService.getTrainRecordByType(year, type);
    }






    /**
     * 隐患治理记录
     */
    @GetMapping("getHiddenDanger")
    public HiddenDangerVO getHiddenDanger(@RequestParam(value = "type", required = false) Integer type, String year) {
        return villageLandInfoService.getHiddenDanger(type, year);
    }


    /**
     * 应急通讯录
     *
     * @return
     */
    @GetMapping("getEmergencyUser")
    public List<ZEmergencyUserDO> getEmergencyUser(@RequestParam(value = "type", required = false) Integer type
    ) {
        LambdaQueryWrapper<ZEmergencyUserDO> wrapper = new LambdaQueryWrapper<>();
        if (type != null) {
            wrapper.eq(ZEmergencyUserDO::getType, type);
        }
        List<ZEmergencyUserDO> list = zEmergencyUserService.list(wrapper);
        return list == null ? new ArrayList<>() : list;
    }


    /**
     * 安全设施清单
     *
     * @return
     */
    @GetMapping("geZGoodsMaterials")
    public List<ZGoodsMaterialsTypeVO> geZGoodsMaterials(
    ) {
        return zGoodsMaterialsService.geZGoodsMaterials();
    }

    /**
     * 设备等级统计
     */
    @GetMapping("getZEquipmentRecord")
    public ZEquipmentRecordVO getZEquipmentRecord() {
        return zEquipmentRecordService.getZEquipmentRecord();
    }
    /**
     * 除险加固
     */
    @GetMapping("getSafetyAppraisal")
    public ZSafetyAppraisalDO getSafetyAppraisal(@RequestParam(value = "year",required = false) String year) {
        return zSafetyAppraisalService.getSafetyAppraisal(year);
    }

    /**
     * 除险加固
     */
    @GetMapping("getSafetyAppraisalFile")
    public List<PubCommonFileVO> getSafetyAppraisalFile(@RequestParam(value = "year",required = false) String year) {
        return zSafetyAppraisalService.getSafetyAppraisalFile(year);
    }

    /**
     * 获取界桩经纬度
     */
    @GetMapping("getIdentification")
    public List<ZIdentificationPlateVO> getIdentification(@RequestParam(value = "type", required = false) Integer type) {
        return zEquipmentRecordService.getIdentification(type);
    }

    @Operation(summary = "查询安全鉴定计划")
    @GetMapping("getSafetyAppraisalPlanList")
    public ResponseDataMessage getSafetyAppraisalPlanList(@RequestParam(value = "year",required = false) Integer year) {
        return  ResponseDataMessage.data(waterLawEnforcementService.getSafetyAppraisalPlanList(year));
    }

    @Operation(summary = "四管安全文件查询")
    @GetMapping("getZForemanageSafeList")
    public ResponseDataMessage getZForemanageSafeList(@RequestParam(value = "type",required = false) String type,@RequestParam(value = "year",required = false)  Integer year) {
        return  ResponseDataMessage.data(waterLawEnforcementService.getZForemanageSafeList(type,year));
    }


    @Operation(summary = "危险源辨识")
    @GetMapping("getZDangerResourceList")
    public ResponseDataMessage getZDangerResourceList(@RequestParam(value = "year",required = false)  Integer year) {
        return  ResponseDataMessage.data(waterLawEnforcementService.getZDangerResourceList(year));
    }
    /**
     * 填报统计
     */
    @RequestMapping("getZCountrySubmit")
    public ZCountrySubmitVO getZCountrySubmit() {

        return waterLawEnforcementService.getZCountrySubmit();

    }


    /**
     * 保障效益已有数据年份
     */
    @GetMapping("getAchievementYear")
    public List<String> getAchievementYear() {
        return villageLandInfoService.getAchievementYear();
    }

    /**
     * 保障效益类型统计
     */
    @GetMapping("getAchievementCount")
    public List<DangerInfoDetailVO> getAchievementCount(@RequestParam(value = "timeYear", required = false) Integer timeYear) {
        return villageLandInfoService.getAchievementCount(timeYear);
    }

    /**
     * 保障水库效益列表
     * @param type
     * @param timeYear
     * @return
     */
    @GetMapping("getAchievementsList")
    public List<ZAchievementsDO> getAchievementsList(@RequestParam(value = "type", required = false) Integer type,
                                                     @RequestParam(value = "timeYear", required = false) Integer timeYear) {
        return villageLandInfoService.getAchievementsList(type, timeYear);
    }

    /**
     * 防洪 2：售电  3:灌溉 效率
     * @param type
     * @param timeYear
     * @return
     */
    @GetMapping("getAchievementsOtherList")
    public List<ZAchievementsOtherVO> getAchievementsOtherList(@RequestParam(value = "type", required = false) Integer type,
                                                               @RequestParam(value = "timeYear", required = false) Integer timeYear) {
        return villageLandInfoService.getAchievementsOtherList(type, timeYear);
    }

    /**
     * 保障水库效益列表 按月统计
     * @param type
     * @param timeYear
     * @return
     */
    @GetMapping("getAchievementsListGroupMonth")
    public List<ZAchievementsDO> getAchievementsListGroupMonth(@RequestParam(value = "type", required = false) Integer type,
                                                               @RequestParam(value = "timeYear", required = false) Integer timeYear) {
        return villageLandInfoService.getAchievementsListGroupMonth(type, timeYear);
    }
    @GetMapping("getPzwlSrhrdsCount")
    public Map<String,Object> getPzwlSrhrdsCount() {
        return villageLandInfoService.getPzwlSrhrdsCount();
    }

    @GetMapping("getSafetyAppraisalRecordList")
    public List<SafetyAppraisalRecordVO> getSafetyAppraisalRecordList(Integer year) {
        return villageLandInfoService.getSafetyAppraisalRecordList(year);
    }

}

